package com.zhang.authoritycenter.controller.sys;

import com.zhang.authoritycenter.service.IUserBaseService;
import com.zhang.infrastructure.api.authority.UserRemoteVo;
import com.zhang.infrastructure.model.KingHoodResponseVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 用户控制器
 *
 * @author jp
 * @date 2024/01/04
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserBaseService userBaseService;

    /**
     * 按ID获取用户
     *
     * @param ids ids
     * @author jp
     * @date 2024/01/05
     */
    @PostMapping("/getUserByIds")
    public Map<Long, UserRemoteVo> getUserByIds(@RequestParam("ids") List<Long> ids) {
        return userBaseService.getUserByIds(ids);
    }

    /**
     * 按姓名或帐户获取id列表
     *
     * @param key 钥匙
     * @return @return {@link List }<{@link Long }>
     * @author jp
     * @date 2024/01/10 17:16
     */
    @PostMapping("/getIdListByNameOrAccount")
    public List<Long> getIdListByNameOrAccount(@RequestParam("key") String key) {
        return userBaseService.getIdListByNameOrAccount(key);
    }


    /**
     * 用户菜单列表
     *
     * @param userId 用户id
     * @return @return {@link KingHoodResponseVO }<{@link List }>
     * @author jp
     * @date 2024/01/15 14:06
     */
    @RequestMapping("/userMenuList")
    public KingHoodResponseVO<List> userMenuList(@RequestParam("userId") Long userId) {
        return KingHoodResponseVO.success(userBaseService.userMenuList(userId));
    }
}
